package models

import (
	"192.168.1.75/go-pkg/helper"
	"gorm.io/gorm"
)

// MaterialAuditLog 素材审核
type MaterialAuditLog struct {
	ID                string `json:"id" gorm:"column:id;primaryKey;type:int;size:64;comment:主键id"`
	MaterialID        string `json:"material_id" gorm:"column:material_id;type:int;size:64;comment:素材ID"`
	MerchantID        string `json:"merchant_id" gorm:"column:merchant_id;type:int;size:64;index:merchant_id;default:0;comment:所属商户"`
	MerchantName      string `json:"merchant_name" gorm:"column:merchant_name;type:string;size:50;not null;default:'';comment:所属商户名称"`
	AuditMerchantID   string `json:"audit_merchant_id" gorm:"column:audit_merchant_id;type:int;size:64;default:0;comment:审核所属商户id"`
	AuditMerchantName string `json:"audit_merchant_name" gorm:"column:audit_merchant_name;type:string;size:50;not null;default:'';comment:审核所属商户名称"`
	AuditUser         string `json:"audit_user" gorm:"column:audit_user;type:string;size:40;default:'';comment:审核用户"`
	AuditUsername     string `json:"audit_username" gorm:"column:audit_username;type:string;size:40;default:'';comment:审核用户名"`
	AuditStatus       int    `json:"audit_status" gorm:"column:audit_status;type:int;size:8;default:2;comment:审核状态:1审核通过 2审核拒绝"`
	AuditAt           int64  `json:"audit_at" gorm:"column:audit_at;autoCreateTime;type:int;size:64;not null;default:0;comment:审核时间"`
}

// TableName 表名
func (MaterialAuditLog) TableName() string {
	return "material_audit_log"
}

// BeforeCreate 自增id
func (l *MaterialAuditLog) BeforeCreate(tx *gorm.DB) (err error) {
	if l.ID == "" {
		// id为空时，自动添加id
		uuid, err := helper.UUID{}.String()
		if err != nil {
			return err
		}
		l.ID = uuid
	}
	return nil
}

// 模式自动注册
func init() {
	Models = append(Models, &MaterialAuditLog{})
}
